//连接数据库
const db=require('mongoose')
db.connect('mongodb://localhost/2021',{useNewUrlParser:true})

//连接对象
var db1=db.connection

db1.on('error',console.error.bind(console,'connection error:'))
db1.once('open',function(){
    console.log('db ok')
})